package com.konne.nightmare.FastPublicOpinion.mvp.presenter;

import com.konne.nightmare.FastPublicOpinion.base.BaseMvpPresenter;
import com.konne.nightmare.FastPublicOpinion.base.OnLoadDataListener;
import com.konne.nightmare.FastPublicOpinion.bean.CurrencyBean;
import com.konne.nightmare.FastPublicOpinion.bean.LoginBean;
import com.konne.nightmare.FastPublicOpinion.http.BaseResponse;
import com.konne.nightmare.FastPublicOpinion.http.RetrofitFactory;
import com.konne.nightmare.FastPublicOpinion.mvp.model.IScanQRCodeLoginModel;
import com.konne.nightmare.FastPublicOpinion.mvp.model.IScanQRCodeModel;
import com.konne.nightmare.FastPublicOpinion.mvp.model.impl.ScanQRCodeLoginModelImpl;
import com.konne.nightmare.FastPublicOpinion.mvp.model.impl.ScanQRCodeModelImpl;
import com.konne.nightmare.FastPublicOpinion.mvp.view.IScanQRCodeLoginView;
import com.konne.nightmare.FastPublicOpinion.mvp.view.IScanQRCodeView;

import org.json.JSONObject;

public class ScanQRCodeLoginPresenter extends BaseMvpPresenter<IScanQRCodeLoginView> {

    private IScanQRCodeLoginModel iScanQRCodeLoginModel;

    public ScanQRCodeLoginPresenter(){
        iScanQRCodeLoginModel = new ScanQRCodeLoginModelImpl();
    }
    public void activation() {
        if (mView == null) return;
        JSONObject params = RetrofitFactory.getJsonParams();
        try {
            params.put("key",mView.key());
        } catch (Exception e) {

        }
        iScanQRCodeLoginModel.postScanQRCode(params, new OnLoadDataListener<CurrencyBean>() {
            @Override
            public void onSuccess(BaseResponse<CurrencyBean> t) {
                getView().activation(t);
                getView().cancelLoadDialog();
            }

            @Override
            public void onFailure(String error) {
                getView().cancelLoadDialog();
            }
        });
    }

}
